package vsa.migrations.junit;

import org.emftext.commons.layout.LayoutInformation;

public class CommentAddPosition {

	private final boolean append;

	private final LayoutInformation layoutinformation;

	public CommentAddPosition (final LayoutInformation layoutInformation, final boolean append) {
		this.layoutinformation = layoutInformation;
		this.append = append;
	}

	public boolean isAppend() {
		return append;
	}	


	public void addComment (final String comment) {

		if (layoutinformation == null)
			throw new IllegalStateException("No layoutinformations available for " + layoutinformation.eContainer());


		if (append) {
			String completeHiddenTokenText = layoutinformation.getHiddenTokenText() + comment;
			layoutinformation.setHiddenTokenText(completeHiddenTokenText);
		} else {
			String completeHiddenTokenText = comment + layoutinformation.getHiddenTokenText();
			layoutinformation.setHiddenTokenText(completeHiddenTokenText);
		}
	}



}
